/**
 * problem_025.cpp
 * Copyright (C) 2011 - xrose
 */

#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

class cNumber
{
    private:
        string sN1, sN2;
    public:
        cNumber();
        cNumber(string, string);
        int cAdd(string&, string, string);
};

cNumber::cNumber()
{
    sN1 = "0";
    sN2 = "0";
}
cNumber::cNumber(string str1, string str2)
{
    sN1 = str1;
    sN2 = str2;
}
int cNumber::cAdd(string &res, string op1, string op2)
{
    int l1, l2, l;
    int rem = 0;
    char c_tem2;
    char c_tem;
    l1 = op1.length();
    l2 = op2.length();
    l = (l1>=l2)?l1:l2;
    if(l2>l1)
    {
        std::swap(op1, op2);
        l2=l1;
        l1=l;
    }
    for(int i=l-1; i>=0; i--)
    {
        c_tem2 = ((i+l2)>=l1)?(op2[i+l2-l1]):'0';
        c_tem = op1[i] + c_tem2 + rem -'0';
        if(c_tem>'9')
        {
            c_tem-=10;
            rem = 1;
            res+=c_tem;
        }else
        {
            rem = 0;
            res+=c_tem;
        }
    }
    if(rem == 1)
    {
        res+='1';
    }
    reverse(res.begin(), res.end());
    return 0;
}

int main (int argc, char const* argv[])
{
    cNumber cStr;
    string f1("1");
    string f2("1");
//    string res;
    //    char res[1001];
    int cnt =2;
    string res;
    cout<<"++"<<res.length()<<endl;
    cStr.cAdd(res, f1, f2);
    while(res.length()<1000)
    {
        cnt++;
//        cout <<"cnt--> "<<cnt<<" res-->"<<res<<": length-->"<<res.length()<<endl;
        f2=f1;
        f1=res;
        res.erase();
        cStr.cAdd(res, f1, f2);
    }
    cout <<"cnt-->"<<++cnt<<" res-->"<<res<<endl;
    return 0;
}
